package com.hctforgreen.greenservice.model;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
 * 获取机型对应资料阅读数
 * @author Tallen Zhai
 *
 */
public class BookClickListEntity extends BaseEntity{

	private static final long serialVersionUID = -8763630950370969985L;

	public ArrayList<BookClickEntity> dataList = null;
	
	public String statusCode = "";
	public String msg = "";
	public final static String STATUS_CODE = "statusCode";
	public final static String MSG = "msg";
	private final static String BOOK_CLICK_LIST = "bookClickList";
	
	public static BookClickListEntity parse(JSONObject jsonObject)throws JSONException{
		BookClickListEntity bean = new BookClickListEntity();
		if(jsonObject.has(STATUS_CODE)){
			bean.statusCode = jsonObject.getString(STATUS_CODE);
		}
		if(jsonObject.has(MSG)){
			bean.msg = jsonObject.getString(MSG);
		}
		/**
		 * 解析columns节点
		 */
		if (jsonObject.has(BOOK_CLICK_LIST)) {
			
			JSONArray jsonArray = jsonObject.getJSONArray(BOOK_CLICK_LIST);
				
			bean.dataList = new ArrayList<BookClickEntity>();
			for (int i = 0; i < jsonArray.length(); i++) {
				JSONObject object = jsonArray.getJSONObject(i);
				BookClickEntity entity = BookClickEntity.parse(object);
				bean.dataList.add(entity);
			}
			
		}
		
		return bean;
	}
	
	public static class BookClickEntity extends BaseEntity{
		private static final long serialVersionUID = -4768147878772825110L;
		public String clickCount = "";
		public String bookId = "";
		
		public final static String CLICK_COUNT = "clickCount";
		public final static String BOOK_ID = "bookId";
		
		
		
		public static BookClickEntity parse(JSONObject jsonObject)
				throws JSONException {
			BookClickEntity bean = new BookClickEntity();
			if (jsonObject.has(BOOK_ID)) {
				bean.bookId = jsonObject.getString(BOOK_ID);
			}
			if (jsonObject.has(CLICK_COUNT)) {
				bean.clickCount = jsonObject.getString(CLICK_COUNT);
				
			}
			
			return bean;
		}
	}
}
